import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GangFightsCreateTeamWindow } from "../GangFightsCreateTeamWindow";
import { GangFightsTeamFaceData } from "../data/GangFightsTeamFaceData";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { FilterConst } from "../../../../component/gconst/FilterConst";
//class GangFightsFaceCellRenderer
    
    export  class GangFightsFaceCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(2, 2, 64, 64, this);
            this._bmpFace = new Object /* flash.display.Bitmap */();
            this._bmpFace.x = 4;
            this._bmpFace.y = 4;
            this.addChild(this._bmpFace);
            LoaderHelp.addResCallBack(ResFileConst.GangFightsFace, this.onResCompl);
            this.doubleClickEnabled = true;
            this.addEventListener(flash.events.MouseEvent.DOUBLE_CLICK, this.ondblClick);
            return;
        }

        /* internal  */ondblClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._teamFaceData) 
            {
                GangFightsCreateTeamWindow.instance.faceId = this._teamFaceData.faceId;
            }
            return;
        }

        /* internal  */onResCompl(): void
        {
            this._isResCompl = true;
            this.updateView();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "gangfightsteamfacedata") 
            {
                this._teamFaceData = arg1 as GangFightsTeamFaceData;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            if (this._isResCompl && this._teamFaceData) 
            {
                this._bmpFace.bitmapData = GlobalClass.getBitmapData(this._teamFaceData.faceBmpName);
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (this.selected) 
            {
                this.filters = [FilterConst.itemChooseFilter];
            }
            else 
            {
                this.filters = [];
            }
            return;
        }

        /* internal */ /* var */_bmpFace: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_teamFaceData: GangFightsTeamFaceData;

        /* internal */ /* var */_isResCompl: Boolean=false;
    }
